<?php
//工作纪录提交及查询
class workrecord extends SDO_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->load->model("workrecords");
	}

	public function addRecord()
	{
		$row['staff_name']		= $_SESSION['username'];
		$row['operate_date']	= date('Y-m-d H:i:s');
		$row['event_id']		= $this->getpara("eventId");
		$row['event_id']		= intval($this->getpara("eventId"));
		if ($row['event_id']<=0)
			die(json_encode(array("success"=>false,"msg"=>"不存在的事件ID")));
		$row['operate_content']	= $this->getpara("operate_content");

		if ($this->workrecords->createRecord($row)) {
			$msg	= "\n---------------".$row['staff_name']." ". $row['operate_date']."------------------\n";
			$msg	.= $row['operate_content'];
			$msg	.= "\n\n";
			die(json_encode(array("success"=>true, "msg"=>$msg)));
		} else {
			die(json_encode(array("success"=>false)));
		}
	}

	public function getRecordsByEventId()
	{
		$eventId	= intval($this->getpara("eventId"));
		if ($eventId<=0)
			die(json_encode(array("success"=>false,"msg"=>"不存在的事件ID")));
		$rows		= $this->workrecords->getRecordsById($eventId);
		die(json_encode($rows));
	}

}